#include "select.hpp"

#define CHECK_RET(v) if((v)==false){return false;}

int main()
{
  TcpSocket cli_sock;
  CHECK_RET(cli_sock.Socket());         //创建套接字
  CHECK_RET(cli_sock.Connect("127.0.0.1",9000));

  //收发数据
  while(1){
    std::string body;
    std::cout<<"client say: ";
    fflush(stdout);
    std::cin >> body;
    CHECK_RET(cli_sock.Send(body));

    body.clear();
    CHECK_RET(cli_sock.Recv(&body));
    std::cout<<"server say: "<< body <<std::endl;
  }

  cli_sock.Close();     //关闭套接字
   
  return 0;
} 
